/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package fr.adama.dto;

import fr.adama.entite.typePerso.BaseLignePaie;
import fr.adama.entite.typePerso.TypeBaseLigne;
import fr.adama.exception.BulletinException;
import java.io.Serializable;
import java.math.BigDecimal;
import javax.validation.constraints.Size;
import org.codehaus.jackson.annotate.JsonIgnore;

/**
 *
 * @author mini-john
 */
public class LigneBulletinPaieModeleDTO implements Serializable {

    private Long id;
    BigDecimal tauxSalarial;
    BigDecimal tauxPatronal;
    BaseLignePaie baselignePaieSalariale;
    BaseLignePaie baselignePaiePatronal;
    TypeBaseLigne typeBaseLigneSalarial;
    TypeBaseLigne typeBaseLignePatronal;
    boolean boldCaracter;
    boolean chargeSalarialImposable;
    Integer positionBulletin;
    @Size(min = 1, message = "{Size.LigneBulletinPaieModele.nom}")
    private String nom;
    @JsonIgnore
    private ModelePaieDTO modelPaie;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public BigDecimal getTauxSalarial() {
        return tauxSalarial;
    }

    public void setTauxSalarial(BigDecimal tauxSalarial) {
        this.tauxSalarial = tauxSalarial;
    }

    public BigDecimal getTauxPatronal() {
        return tauxPatronal;
    }

    public void setTauxPatronal(BigDecimal tauxPatronal) {
        this.tauxPatronal = tauxPatronal;
    }

    public BaseLignePaie getBaselignePaieSalariale() {
        return baselignePaieSalariale;
    }

    public void setBaselignePaieSalariale(BaseLignePaie baselignePaieSalariale) {
        this.baselignePaieSalariale = baselignePaieSalariale;
    }

    public BaseLignePaie getBaselignePaiePatronal() {
        return baselignePaiePatronal;
    }

    public void setBaselignePaiePatronal(BaseLignePaie baselignePaiePatronal) {
        this.baselignePaiePatronal = baselignePaiePatronal;
    }

    public TypeBaseLigne getTypeBaseLigneSalarial() {
        return typeBaseLigneSalarial;
    }

    public void setTypeBaseLigneSalarial(TypeBaseLigne typeBaseLigneSalarial) {
        this.typeBaseLigneSalarial = typeBaseLigneSalarial;
    }

    public TypeBaseLigne getTypeBaseLignePatronal() {
        return typeBaseLignePatronal;
    }

    public void setTypeBaseLignePatronal(TypeBaseLigne typeBaseLignePatronal) {
        this.typeBaseLignePatronal = typeBaseLignePatronal;
    }

    public String getNom() {
        return nom;
    }

    public void setNom(String nom) {
        this.nom = nom;
    }

    public ModelePaieDTO getModelPaie() {
        return modelPaie;
    }

    public void setModelPaie(ModelePaieDTO modelPaie) {
        this.modelPaie = modelPaie;
    }

    public boolean getBoldCaracter() {
        return boldCaracter;
    }

    public void setBoldCaracter(boolean boldCaracter) {
        this.boldCaracter = boldCaracter;
    }

    public boolean getChargeSalarialImposable() {
        return chargeSalarialImposable;
    }

    public void setChargeSalarialImposable(boolean chargeSalarialImposable) {
        this.chargeSalarialImposable = chargeSalarialImposable;
    }

    public Integer getPositionBulletin() {
        return positionBulletin;
    }

    public void setPositionBulletin(Integer positionBulletin) {
        this.positionBulletin = positionBulletin;
    }

    public BigDecimal getMontantSalarial(BigDecimal base) throws BulletinException {
        switch (typeBaseLigneSalarial) {
            case Pourcentage:
                return base.multiply(tauxSalarial).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP);
            case Nombre:
                return base.multiply(tauxSalarial).setScale(2, BigDecimal.ROUND_HALF_UP);
            case Aucun:
                return BigDecimal.ZERO;
            default:
                throw new BulletinException(typeBaseLigneSalarial + " inconnu");
        }
    }

    public BigDecimal getMontantPatronal(BigDecimal base) throws BulletinException {
        switch (typeBaseLignePatronal) {
            case Pourcentage:
                return base.multiply(tauxPatronal).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP);

            case Nombre:
                return base.multiply(tauxPatronal).setScale(2, BigDecimal.ROUND_HALF_UP);

            case Aucun:
                return BigDecimal.ZERO;
            default:
                throw new BulletinException(typeBaseLigneSalarial + " inconnu");
        }

    }

}
